 1 #!/usr/bin/python
   2 
   3 # customdialog2.py
   4 
   5 import wx
   6 
   7 class MyDialog(wx.Dialog):
   8     def __init__(self, parent, id, title):
   9         wx.Dialog.__init__(self, parent, id, title)
  10 
  11         vbox = wx.BoxSizer(wx.VERTICAL)
  12         stline = wx.StaticText(self, 11, 'Discipline ist Macht.')
  13         vbox.Add(stline, 1, wx.ALIGN_CENTER|wx.TOP, 45)
  14         sizer =  self.CreateButtonSizer(wx.NO|wx.YES|wx.HELP)
  15         vbox.Add(sizer, 0, wx.ALIGN_CENTER)
  16         self.SetSizer(vbox)
  17         self.Bind(wx.EVT_BUTTON, self.OnYes, id=wx.ID_YES)
  18 
  19     def OnYes(self, event):
  20         self.Close()
  21 
  22 class MyFrame(wx.Frame):
  23     def __init__(self, parent, id, title):
  24         wx.Frame.__init__(self, parent, id, title)
  25         panel = wx.Panel(self, -1)
  26         wx.Button(panel, 1, 'Show custom Dialog', (50,50))
  27         self.Bind(wx.EVT_BUTTON, self.OnShowCustomDialog, id=1)
  28 
  29     def OnShowCustomDialog(self, event):
  30         dia = MyDialog(self, -1, '')
  31         val = dia.ShowModal()
  32         dia.Destroy()
  33 
  34 class MyApp(wx.App):
  35     def OnInit(self):
  36         frame = MyFrame(None, -1, 'customdialog2.py')
  37         frame.Show(True)
  38         frame.Centre()
  39         return True
  40 
  41 app = MyApp(0)
  42 app.MainLoop()
